<template>
  <div>
    <p>money: {{money}}</p>
    <p>age: {{$attrs.age}}</p>
    <button @click="addN(3)">+n</button>
  </div>
</template>

<script>
export default {
  name: 'Child',
  // 儿子通过 props 接收
  props: {
    money: {
      type: Number,
      default: 10
    },
  },
  // 接收 context
  setup (props, { emit, attrs, slots }) {
    // emit => this.$emit
    // attrs => this.$attrs，非 props 属性组成的对象
    // console.log(attrs)
    // slots => this.$slots，插槽信息
    console.log(slots)
    const addN = (num) => {
      emit('updateMoney', num)
    }
    return {addN}
  }
}
</script>

<style lang="scss" scoped>

</style>